package com.zipking.cloud.springbootmybatis;

import com.zipking.cloud.springbootmybatis.config.PropertiesListenerConfig;
import com.zipking.cloud.springbootmybatis.redislock.EnableDistributedLock;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.Executors;

@MapperScan("com.zipking.cloud.springbootmybatis.persistance.mapper")
@SpringBootApplication
@EnableAsync
 @EnableDistributedLock
 //开启定时任务
public class SpringBootMybatisApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication application = new SpringApplication(SpringBootMybatisApplication.class);
        // 配置文件名称
        String[] config = {"channelcode.conf"};
        // 根据application.yml配置环境,初始化配置文件
        application.addListeners(new PropertiesListenerConfig(config));
        application.run(args);
    }

    @Bean
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootMybatisApplication.class);
    }

}
